/*
 * realTimeAnswer.js
 */

var gradeAndSubjectId;
var gradeAndSubjectContent;

$(document).ready(function(){
	
 });

function chooseGradeAndSubject(id, contentId){
	gradeAndSubjectId = id;
	gradeAndSubjectContent = contentId;
	document.onmousemove = mouseMove;
	var absoluteTop = GetAbsoluteLocation(document.getElementById(id)).absoluteTop;
	var absoluteLeft = GetAbsoluteLocation(document.getElementById(id)).absoluteLeft + 380;
	
	$('#' + contentId).css("top", absoluteTop);
	$('#' + contentId).css("left", absoluteLeft);
	$('#' + contentId).removeClass("hide");
	
}

function mouseMove(ev){ 
	var ev= ev || window.event; 
	var mousePos = mouseCoords(ev); 
	var absoluteTop = GetAbsoluteLocation(document.getElementById(gradeAndSubjectId)).absoluteTop;
	var absoluteLeft = GetAbsoluteLocation(document.getElementById(gradeAndSubjectId)).absoluteLeft;
	
	if(mousePos.x > absoluteLeft + 390 ||
			mousePos.x < absoluteLeft ||
			mousePos.y > absoluteTop + 200 ||
			mousePos.y < absoluteTop){
		
		$('#' + gradeAndSubjectContent).addClass("hide");
	}
} 

function mouseCoords(ev) { 
	if(ev.pageX || ev.pageY){ 
		return {x:ev.pageX, y:ev.pageY}; 
	} 
	return { 
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, 
		y:ev.clientY + document.body.scrollTop - document.body.clientTop 
	}; 
} 

 
